﻿//年报数据
function fillSheetAnnual(context, input, result) {
    var sheet = context.workbook.worksheets.getItem("年报数据");


    var address = result.annual.address;
    var columnCount = parseInt(result.annual.columnCount);
    var datas = result.annual.datas;
    
    var range = sheet.getUsedRangeOrNullObject();
    range.load('columnCount,rowCount');
    return context.sync().then(function () {
        var maxUsedColumnCount = range.columnCount;
        var maxUsedRowCount = range.rowCount;
        var startColumn = 3 + columnCount;

        //删除多余的列
        var clearRange = sheet.getRangeByIndexes(0, startColumn, maxUsedRowCount, maxUsedColumnCount);
        clearRange.clear();
        return context.sync().then(function () {
            if (datas.length > 0) {
                var range = sheet.getRange(address);
                range.values = datas;
            }
            
            return context.sync();
        });
    }).catch(function (e) {
        console.log(e);
    });
}
 